import {ApiBearerAuth, ApiBody, ApiConsumes, ApiOperation, ApiTags} from "@nestjs/swagger";
import {BadRequestException, Body, Controller, Logger, Post} from "@nestjs/common";
import {Public} from "~/modules/auth/decorators/public.decorator";
import {AccessTagDto} from "~/modules/assess/tag/tag.dto";
import {AuthUser} from "~/modules/auth/decorators/auth-user.decorator";
import {AccessTagService} from "~/modules/assess/tag/tag.service";

@ApiTags("AccessTag - 评估标签")
@ApiBearerAuth()
@Controller('access/tag')
export class TagController {
  private readonly logger = new Logger(TagController.name)

  constructor(
    private readonly tagService: AccessTagService
  ) {
  }

  @Post("add")
  @ApiOperation({summary: '评估标签'})
  @ApiBody({type: AccessTagDto})
  async addTag(@Body() accessTagDto: AccessTagDto){
    try {
      // 添加标签
      return await this.tagService.save(accessTagDto)
    }
    catch (error: any) {
      throw new BadRequestException(error?.message ?? '添加标签失败')
    }
  }
}
